package com.atguigu.gulimall.search.controller;

import com.atguigu.common.utils.R;
import com.atguigu.gulimall.search.service.MallSearchService;
import com.atguigu.gulimall.search.vo.SearchParam;
import com.atguigu.gulimall.search.vo.SearchResult;
import org.apache.http.HttpRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/search")
public class SearchController {

    @Autowired
    MallSearchService searchService;

    @GetMapping("/list")
    public R listPage(SearchParam param, HttpServletRequest request){
        param.set_queryString(request.getQueryString());
        SearchResult result  =searchService.search(param);
        return R.ok().put("data","result");
    }
}
